package com.zrrd.gmall.webAll.controller;

import com.zrrd.gmall.common.result.Result;
import com.zrrd.gmall.item.feign.ItemFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@Controller
public class WebController {
    @Autowired
    private ItemFeignClient itemFeignClient;
    @GetMapping("{skuId}.html")
    public String getItem(@PathVariable("skuId") Long skuId, Model model){
        //fegin请求商品汇总服务
        Result<Map> item = itemFeignClient.getItem(skuId);
        Map map = item.getData();

        //存入请求对象
        model.addAllAttributes(map);
        return "/item/index";
    }
}
